{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "3926fa67-2d65-4aa7-ab35-4f72708c290b",
   "metadata": {},
   "source": [
    "# Python的基本语法"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "99b568c3-da9b-4db6-8767-264dd14863b5",
   "metadata": {},
   "source": [
    "## Python的变量名\n",
    "\n",
    "python里规定，数据存入计算机的时候，需要给每一个存进去的数据进行命名。这个名字的命名（naming）有如下规则；\n",
    "\n",
    "- 变量名必须由字母、数字、以及下划线组成。\n",
    "- 变量名的第一个字符不能是数字\n",
    "- 变量名不能和“保留字”重复"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fa328c05-7c32-486c-9f0e-124e29a5de4e",
   "metadata": {},
   "source": [
    "## python的变量类型\n",
    "\n",
    "* 整数（Integer）\n",
    "* 浮点数（float）\n",
    "* 字符串、文本（siring,text）\n",
    "* 布尔 Boolean True/False\n",
    "* Complex a+bj\n",
    "\n",
    "在编程中，我们可以设定变量的type"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "bdc071cc-9a08-4912-b039-2ad4b9326dd8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "80\n"
     ]
    }
   ],
   "source": [
    "student_number=80\n",
    "print(student_number)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "fa27c4f6-8e63-4b8c-93f1-ed5b6e63f1d3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "904923385897135968635993330451994402947962681462442739395945305327974242620886079862171919815773916062137678512046882180356624800604291530719893095286154551116680012572086803199157922039351668478564828348301753851143492353748173455041191368048498800957203432864824321737565305767651292628878449326573851129626299643156164006373606978104288368619463474679817790736225593640367076086526860949335086889282591623958899999030416805981546506749160652353984617143198124534369829314662231891921802116654672691150163416611310214731835685336083791098159986712848540463380146580690263454169758498566538040283235414152791831337593439444621511310090438179023511669703673763956387336503489038555475153925609024892127654203399307885287010407165087303556463402104249596842331426415525300653110053828399397903205357713789894870863251291459593595201054980469493300664198318677355414365010851955548694739119104090220233140788420859415456152644287308234078905829203811259753933035275480038057609620799308776526343252218093571949400396210984799378493274214493165068279520881815164603318874389878937542957605014381356061059994092564793420317582087577117177337626416509150218644192106716925196995812374694889330885145792545242433594855481697026358810825184757759935422851061660629603404087764810046653789381560074364474182774292894551853222460145230888637407442107011588271876801389494627762853045057208646205607006661255813799080395885457915508673465373921100097736951463981366585143929393417244108340751863808054676992455065838053595310271331759143203555316304314251716764567094137578074061132119862408874390848886395852792960864168601792788278318160137904725260688818200212497979747376338411781124255038680896140093227362659027162713194890382243266772509375096737692404023569670426915056835458749926163985256792853781964089923834318862117838128735569807805351308189084989769489964408778532697647602700282950821524204053787874658551812707648093031690343619645467904689510727375518396966457071841305216156347877121685546777678309421329334333950023546927391264996410340738923279172434249372049444083417317264151167058316398213637536972859458418643841045234965050333775282590668237489897775711992749330416321184641859741493413207330861021636211695796890541696093027330978109081670597186421777865316335568268866847863125613923464409844281877208541827346630071361261867264461942278221180886866038139173352394382234246436410919991789177435673334776810354886604183268250331679892996979175063172926111707167198988243425047912706142878386347158445445591102587506888005640161498171679357966807984060508691288681969337226449111719514569649584122429236008770062941505213765399433830889823697501728179680768772138041764144904770378170664744008068818519908732748955581235528133962380590442055397577789081529546432947644282480004693282468769435839804376574018464714415877893064638696587341337302512708701490668177002555837586724984868715778513594603545480341027561264023573773303851210892680448436222398163440132775762853207138057827113307234300824712023342158555900846805612907241505922208073502427151381654140438487897137928537698888446898147168193058173312004926859743133949522199995615524876873255809031695967215769079935733193721979907314034693042338529314763723194210563682373779442613729638860299539363371280264299237537468883139150469536810933163407660360896994875462207011514046858224784931169192381967468686722699491276553444179847632286712599329618653107733053483010527841643072968036829514977400340066251763328207284025211584908980266699661667524249578619916906867512040194805177552703325877373006584049976097235088187395421164165166094064459452363384380694012449976128470800253126328810143168379290430540593182289272142298431994458570517660385235378152301536784502584160105719811652504606694771247419726895637829932351658449968923764340374310375005018692236541404840118114549173569827683049363850020327899649931006693481683342743602024169581762417279247879686614711509052491002523222444916196015880503158449149909989999\n"
     ]
    }
   ],
   "source": [
    "print(9999**999)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "dbe7b227-1090-4979-b245-7c81cae77457",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'float'>\n"
     ]
    }
   ],
   "source": [
    "a =3\n",
    "pi =3.14\n",
    "print(type(pi+a))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "ac2947bb-28cb-41b8-8abb-e764bd74b435",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "yang\n"
     ]
    }
   ],
   "source": [
    "name =\"yang\"\n",
    "print (name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "b554d333-467e-4627-aebe-b007686d6e07",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'str'>\n"
     ]
    }
   ],
   "source": [
    "name =\"\"\"\n",
    "im,\n",
    "i,\n",
    "m\n",
    "\n",
    "\"\"\"\n",
    "print(type(name))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "1fd4ba89-322b-444a-a403-54b663d3bf56",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n"
     ]
    }
   ],
   "source": [
    "x=1\n",
    "y=1\n",
    "print(x==y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "7ff04c48-ccd4-48bf-97bf-ea02210ccf88",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(1+2j)\n"
     ]
    }
   ],
   "source": [
    "a=1+2j\n",
    "print(a)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5b87e805-1a73-4790-971e-e8f8b6389f36",
   "metadata": {},
   "source": [
    "## Python的运算符\n",
    "\n",
    "+ - * / ** = ==\n",
    "> < <= >= !=\n",
    " += ()\n",
    "and or not>& | !\n",
    "%>mod  取模"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "7996bd29-d8d9-40cb-8437-2d1623e5665e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n"
     ]
    }
   ],
   "source": [
    "a=1\n",
    "b=2\n",
    "print(a!=b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "96c70671-a1b2-49d1-86c0-94ffaaf4f502",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n"
     ]
    }
   ],
   "source": [
    "print(10%2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "baa5abc8-8ccc-4e92-9554-104853891a9e",
   "metadata": {},
   "source": [
    "# Python的输入与输出\n",
    "\n",
    "-print()函数 function\n",
    "-input()函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "9ae061e3-0774-4891-9baa-63a5fe95ec38",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3.14 1\n"
     ]
    }
   ],
   "source": [
    "a=3.14\n",
    "b=1\n",
    "print(a,b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "cb209f6c-812b-4c7c-9595-edc3fa914215",
   "metadata": {},
   "outputs": [
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入半径: 3\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "半径是 3 的圆面积是： 28.26\n",
      "<class 'int'>\n"
     ]
    }
   ],
   "source": [
    "radius=input(\"请输入半径:\")\n",
    "\n",
    "radius=eval(radius)\n",
    "print(\"半径是\", radius ,\"的圆面积是：\" ,radius**2*3.14)\n",
    "print(type(radius))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "a6967754-59cd-4590-afd9-a278280a0c2f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      " 3.5\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'float'>\n"
     ]
    }
   ],
   "source": [
    "# 请用input（）输入，赋值给x，然后eval（x）的值赋值给y,\n",
    "#再输出y的类型\n",
    "#  comment 注释\n",
    "\n",
    "x=input()\n",
    "\n",
    "y=eval(x)\n",
    "\n",
    "print(type(y))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "53126a6f-16df-40f7-bdb2-7f4d2edfa6ca",
   "metadata": {},
   "outputs": [],
   "source": [
    "# fString\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "fba4c2ce-4bd1-48a3-9f0c-3f0b3d4aa59c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "输入一个摄氏度数字： 5\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "相当于华氏度41.00\n"
     ]
    }
   ],
   "source": [
    "c =input(\"输入一个摄氏度数字：\")\n",
    "c =eval(c)\n",
    "print(f\"相当于华氏度{c*1.8+32:.2f}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "c68e714e-cce7-445b-82be-3b181cf33a2f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "输入一个华氏度数字： 6\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "相当于摄氏度-14.44\n"
     ]
    }
   ],
   "source": [
    "F =input(\"输入一个华氏度数字：\")\n",
    "F =eval(F)\n",
    "print(f\"相当于摄氏度{(F-32)/1.8:.2f}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3e557e29-bff3-43e7-8a5b-734b0405c57f",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda env:base] *",
   "language": "python",
   "name": "conda-base-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
